package com.device.util;

import java.io.Serializable;

/**
 * @author:刘高博
 * @date:2017年4月19日
 * @说明:ajax返回封装
 **/
public class Message implements Serializable{
	private static final long serialVersionUID = 4668030721700265989L;
	/**异常码(200:成功400:失败)*/
    private String code;
    /**提示信息*/
    private String msg;
    /**数据集合*/
    private Object[] data;
    /**视图*/
    public Message(String msg){
    	this.msg = msg;
    }
	public Message(String code,String msg){
		this.code = code;
		this.msg = msg;
	}
	
	public Message(String code,String msg,Object... objs){
		this.code = code;
		this.data = objs;
		this.msg = msg;
	}
	
	public static Message done(String msg,Object... datas){
		return new Message("200",msg,datas);
	}
	public static Message done(Object... datas){
		return new Message("200","\u8BF7\u6C42\u6210\u529F!",datas);
	}
	public static Message warn(String code,String msg,Object... objs){
		return new Message(code,msg,objs);
	}
	public static Message fail(String msg,Object... objs){
		return new Message("400",msg,objs);
	}
	public static String view(String url){
		return new Message(url).getMsg();
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Object[] getData() {
		return data;
	}
	public void setData(Object[] data) {
		this.data = data;
	}
}
